package com.puman.beautyfarmcounselor.ui.home.adpter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.puman.beautyfarmcounselor.R;
import com.puman.beautyfarmcounselor.ui.customer.model.Consume;

/**
 * Created by Curry on 2015/6/12.
 */
public class ConsumerecordListAdapter extends RecyclerView.Adapter<ConsumerecordListAdapter.ViewHolder> {

    private Context context;
    Consume consume;

    public ConsumerecordListAdapter(Context context, Consume consume) {
        this.context = context;
        this.consume = consume;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        private final TextView consumeRecordStore;
        private final TextView consumeRecordTime;
        private final TextView consumeRecordPrice;
        public ViewHolder(View v) {
            super(v);
            consumeRecordStore = (TextView) v.findViewById(R.id.consumeRecordStore);
            consumeRecordTime = (TextView) v.findViewById(R.id.consumeRecordTime);
            consumeRecordPrice = (TextView) v.findViewById(R.id.consumeRecordPrice);
        }

        public TextView getConsumeRecordStore() {
            return consumeRecordStore;
        }

        public TextView getConsumeRecordTime() {
            return consumeRecordTime;
        }

        public TextView getConsumeRecordPrice() {
            return consumeRecordPrice;
        }
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.consume_recordlist_item, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.getConsumeRecordStore().setText(consume.getData().getRecord_list().get(position).getStore_name());
        holder.getConsumeRecordTime().setText(consume.getData().getRecord_list().get(position).getConsume_time());
        holder.getConsumeRecordPrice().setText("¥"+consume.getData().getRecord_list().get(position).getConsume_sum());
    }

    @Override
    public int getItemCount() {
        return consume.getData().getRecord_list().size();
    }


}
